<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of School
 *
 * @author 耿鸿飞 <15911185633>
 */
class Sys_School extends Model
{
    protected $table_univ = "sys_univs";
    protected $table_school = 'sys_schools';
    /**
     * 根据省份得到大学列表
     * @param type $pid
     * @return type
     */
    public function getUnivs($pid = 0){
        $rs = array();
        $sql = sprintf("SELECT * FROM %s WHERE Fstatus='Yes'",$this->table_univ);
        if($pid > 0){
            $sql = sprintf("SELECT * FROM %s WHERE Fstatus='Yes' AND Fpid=%d",$this->table_univ,$pid);
        }
        $list = $this->getResults($sql);
        if($list){
            foreach($list AS $val){
                $rs[$val['Fuid']] = $val;
            }
        }
        return $rs;
    }
    /**
     * 根据大学id的到大学的学院或者院系信息
     * @param type $fuid
     * @return type
     */
    public function getSchools($fuid = 0){
        $rs = array();
        $sql = sprintf("SELECT * FROM %s WHERE Fstatus='Yes'",$this->table_school);
        if($pid > 0){
            $sql = sprintf("SELECT * FROM %s WHERE Fstatus='Yes' AND Fpid=%d",$this->table_school,$fuid);
        }
        $list = $this->getResults($sql);
        if($list){
            foreach($list AS $val){
                $rs[$val['Fuid']] = $val;
            }
        }
        return $rs;
    }
}

?>
